package com.example.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private boolean success;
    private Integer code;
    private String message;
    private Object data;

    public static Result success(String message, Object data) {
        return new Result(true, 200, message, data);
    }

    public static Result success(String message) {
        return success(message, null);
    }

    public static Result success(Object data) {
        return success("success", data);
    }

    public static Result success() {
        return success((Object) null);
    }


    public static Result error(int code, String message) {
        return new Result(false, code, message, null);
    }

    public static Result error(String message) {
        return error(500, message);
    }

}